import { IapProductInfo } from "./SDK/IapSDKManager";
import { TaskInfo } from "./TaskManager";

export type FeatureKey = 'obstacle' | 'pipe' | 'block_blind' | 'adult_blind' | 'joint';
export type FeatureParam = { start_stage: number };

export type ItemKey = 'swapper' | 'magnet' | 'balloon';
export type ItemParam = { init_count: number, cost_coin: number, start_stage: number };

export type IapKey = 'coin_0' | 'coin_1' | 'coin_2' | 'coin_3' | 'coin_4' | 'coin_5' | 'noads_0' | 'noads_1' | 'newbie_0' | 'newbie_1' | 'bundle_0' | 'bundle_1' | 'bundle_2' | 'bundle_3' | 'bundle_4' | 'savingpot_0';
export type TaskGroupKey = 'daily' | 'daily_total';

export const DevConfig = {

    get DEVELOPER_TOOLS() { return true || globalThis.dev }, // 开发者工具，正式发布需要改成false
    get DATA_REPORT() { return true; }, // 数据上报, 正式发布需要改成true

    get STAGE_INIT_ANIM() { return false; }, // 关卡初始动画，大夫说太乱了，维持 false

    get ADS_REWARDS_AUTO_PASSED() { return false }, // 激励广告自动成功返回（用于测试）正式发布需要改成false 
    get IAP_AUTO_PASSED() { return false }, // IAP项直接通过（用于测试）正式发布需要改成false 

    get STAGE_NUM_MAX() { return 2; }, // 当前最大关卡号
    get STAGE_RANDOM_REPEAT() { return false; }, // 随机重复, false则会在最大关卡后胜利后依然维持，不进行+1

    get COIN_INIT() { return 500; }, //  初始金币
    get COIN_COMPLETED_EARN() { return 10; }, // 胜利后赢取金币
    get COIN_COMPLETED_EARN_ADS() { return 20; }, // 胜利后看广告赢取金币数量

    get COIN_LOSE_CONTINUE_NEED() { return 800 }, // 失败后想继续，每次继续增加需要金币的数量，

    get HEART_INIT() { return 5; }, // 体力初始值
    get HEART_RESTORE_MAX_COUNT() { return 5; }, // 恢复体力的上限,
    get HEART_RESTORE_NEED_SECOND() { return 30 * 60; }, // 回复一个体力需要的秒数

    get HEART_REFILL_NEED_COIN() { return 800; }, // 补满到体力上限，需要花费金币

    ITEM_PARAM: {
        'swapper': {
            init_count: 1,  // 初始数量
            cost_coin: 300, // 花费金币
            start_stage: 4, // 出现关卡
        },
        'magnet': {
            init_count: 1,  // 初始数量
            cost_coin: 500, // 花费金币
            start_stage: 5, // 出现关卡
        },
        'balloon': {
            init_count: 1,  // 初始数量
            cost_coin: 400,// 花费金币
            start_stage: 10, // 出现关卡
        }
    } as Record<ItemKey, ItemParam>,

    FEATURE_PARAM: {
        // 'obstacle': { start_stage: 3 }, // 路障(不需要提示)
        'pipe': { start_stage: 6 },// 管道
        'block_blind': { start_stage: 15 }, // 问号泳圈
        'joint': { start_stage: 37 }, // 连对
        'adult_blind': { start_stage: 45 }, // 问号小人
    } as Record<FeatureKey, FeatureParam>,

    get FREE_COINS() { return 80; }, // 每日看广告可领取的免费金币数

    allProductIds: ['game106.coin_0', 'game106.coin_1', 'game106.coin_2', 'game106.coin_3', 'game106.coin_4', 'game106.coin_5', 'game106.noads_0', 'game106.noads_1', 'game106.newbie_0', 'game106.newbie_1', 'game106.bundle_0', 'game106.bundle_1', 'game106.bundle_2', 'game106.bundle_3', 'game106.bundle_4', 'game106.savingpot_0'],

    iap: {
        coin_0: { flag: 'coin_0', giftType: 'coin', productId: 'game106.coin_0', price: 199, provide: { coin: 1000 }, iconId: 2, discount: 0 },
        coin_1: { flag: 'coin_1', giftType: 'coin', productId: 'game106.coin_1', price: 499, provide: { coin: 2600 }, iconId: 3, discount: .95 },
        coin_2: { flag: 'coin_2', giftType: 'coin', productId: 'game106.coin_2', price: 999, provide: { coin: 5500 }, iconId: 4, discount: .90 },
        coin_3: { flag: 'coin_3', giftType: 'coin', productId: 'game106.coin_3', price: 1999, provide: { coin: 11700 }, iconId: 5, discount: .85 },
        coin_4: { flag: 'coin_4', giftType: 'coin', productId: 'game106.coin_4', price: 2999, provide: { coin: 19000 }, iconId: 6, discount: .80 },
        coin_5: { flag: 'coin_5', giftType: 'coin', productId: 'game106.coin_5', price: 5999, provide: { coin: 54000 }, iconId: 7, discount: .55 },

        noads_0: { flag: 'noads_0', giftType: 'noads', productId: 'game106.noads_0', price: 599, provide: { noads: 1, inf_heart_sec: 900 }, discount: 0 },
        noads_1: { flag: 'noads_1', giftType: 'noads', productId: 'game106.noads_1', price: 799, provide: { noads: 1, coin: 1500, inf_heart_sec: 900 }, discount: .70 },

        newbie_0: { flag: 'newbie_0', giftType: 'newbie', productId: 'game106.newbie_0', price: 199, provide: { coin: 2000, swapper: 1, balloon: 1, inf_heart_sec: 1800, noads_sec: 900 }, discount: .10, limited: 1 },
        newbie_1: { flag: 'newbie_1', giftType: 'newbie', productId: 'game106.newbie_1', price: 599, provide: { coin: 4000, swapper: 5, balloon: 5, inf_heart_sec: 3600, noads_sec: 1800 }, discount: .30, limited: 1 },

        bundle_0: { flag: 'bundle_0', giftType: 'bundle', productId: 'game106.bundle_0', price: 699, provide: { coin: 2500, swapper: 1, magnet: 1 } },
        bundle_1: { flag: 'bundle_1', giftType: 'bundle', productId: 'game106.bundle_1', price: 1299, provide: { coin: 5500, swapper: 3, magnet: 3, inf_heart_sec: 1800 } },
        bundle_2: { flag: 'bundle_2', giftType: 'bundle', productId: 'game106.bundle_2', price: 2499, provide: { coin: 11700, swapper: 6, magnet: 6, inf_heart_sec: 3600, noads_sec: 900 } },
        bundle_3: { flag: 'bundle_3', giftType: 'bundle', productId: 'game106.bundle_3', price: 4999, provide: { coin: 25000, swapper: 10, magnet: 10, inf_heart_sec: 10800, noads_sec: 3600 }, discount: .60 },
        bundle_4: { flag: 'bundle_4', giftType: 'bundle', productId: 'game106.bundle_4', price: 9999, provide: { coin: 55000, swapper: 20, magnet: 20, inf_heart_sec: 21600, noads_sec: 10800 }, discount: .40 },

        savingpot_0: { flag: 'savingpot_0', giftType: 'savingpot', productId: 'game106.savingpot_0', price: 199, provide: { dynamic_reward_id: 1 } }
    } as Record<IapKey, IapProductInfo>,

    get INTERSTITIALAD_FROM_STAGE_NUM() { return 8; }, // 插屏广告从第几关开始，包括这一关的结算画面本身的所在关卡,
    get INTERSTITIALAD_CD() { return 100; }, // 插屏广告 CD
    get REWARDEDAD_FROM_STAGE_NUM() { return 11; }, // 激励广告从第几关开始，包括这一关的结算画面本身的所在关卡,

    get DIRECT_START_LESSEQUAL_STAGE_NUM() { return 0; }, // 在小于等于这个关卡号之前，自动开始游戏(即不回主菜单或从主菜单开始)

    get STAGE_CHEST() { // 宝箱随机信息
        return {
            stage2: { provide: { coin: 50 } },
            stage5: { provide: { coin: 100 } },
            stageMod5: {
                probability: [
                    { provide: { coin: 100 }, p: .3 },
                    { provide: { swapper: 1 }, p: .3 },
                    { provide: { balloon: 1 }, p: .3 },
                    { provide: { magnet: 1 }, p: .1 },
                ]
            }
        }
    },

    get SAVING_POT() { // 存钱罐相关信息
        return {
            INC_STEP: 100, // 每次胜利增加多少金币
            UNLOCK_COUNT: 1000, // 达到后可以购买
            COIN_CAPACITY: 1500, // 总容量
            EXP_SEC: 86400, // 达到上限后开始计过期时间
        }
    },

    get REQUEST_NOTIFICATION_GREATEREQUAL_STAGE_NUM() { return 10; }, // 大于等于这个关卡号之后，返回首页时请求通知权限

    task: {
        daily: { // 每日任务
            101: { taskId: 101, taskType: 'login', times: 1, provide: { coin: 20 } },
            102: { taskId: 102, taskType: 'use_item', times: 1, provide: { coin: 30 } },
            103: { taskId: 103, taskType: 'spin_wheel', times: 1, provide: { coin: 60 } },
            104: { taskId: 104, taskType: 'win', times: 1, provide: { swapper: 1 } },
        },
        daily_total: { // 每日任务全完成
            100: {
                taskId: 100, taskType: 'daily_task', times: 4, provide: { dynamic_reward_id: 2 }
            }
        }
    } as Record<TaskGroupKey, Record<number, TaskInfo>>,

    get TASK_DAILY_CHEST() {
        return {
            daily_total: {
                probability: [
                    { provide: { coin: 100 }, p: .3 },
                    { provide: { swapper: 1 }, p: .3 },
                    { provide: { balloon: 1 }, p: .3 },
                    { provide: { magnet: 1 }, p: .1 },
                ]
            }
        };
    },

    get LUCKYWHEEL() {
        return {
            UNLOCK_STAGE_NUM: 5, // 从第几关解锁
            DAILY_TIMES: 2, // 每日可转动几次
            rewards: {
                probability: [
                    { idx: 0, provide: { coin: 50 }, p: .1 },
                    { idx: 1, provide: { magnet: 1 }, p: .1 },
                    { idx: 2, provide: { coin: 100 }, p: .3 },
                    { idx: 3, provide: { balloon: 1 }, p: .15 },
                    { idx: 4, provide: { coin: 200 }, p: .1 },
                    { idx: 5, provide: { swapper: 1 }, p: .15 },
                    { idx: 6, provide: { coin: 500 }, p: .05 },
                    { idx: 7, provide: { magnet: 2 }, p: .05 },
                ]
            }
        }
    },

}
globalThis.DevConfig = DevConfig;